﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace WinRTConverters.WP8.Values
{
    public class ChoiceDoubleAccordingToBooleanConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value != null)
            {
                double valueParam;
                if (double.TryParse(parameter.ToString(), out valueParam))
                {
                    return (bool)value ? valueParam : double.NaN;
                }
                return double.NaN;
            }
            return double.NaN;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
